# -*- coding:utf-8 -*-
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.contrib.auth.models import User

# Create your models here.
CASH_CHOICES = (
        ('RMB', _('Renmingbi')),
        ('USD', _("US dollar")),
        ('GBP', _("Great Britain Pound")),
        ('EUR', _('euro')),
        ('HKD', _('HongKong dollar')),
        ('JPY', _('Japanese Yuan')),
        )
AGENT_CHOICES = (
        ('BOC', _('Bank of China')),
        ('CCB', _('China Construction Bank')),
        ('ICBC', _('Industrial and Commercial Bank of China')),
        ('ABC', _('Agricultural Bank of China')),
        ('CMBC', _("China Minsheng Banking Co., ltd")),
        ('CMB', _("China Merchants Bank ltd")),
        ("CIB", _("Industrial Bank Co., ltd")),
        ("BOB", _("bank of beijing")),
        ("BCM", _("Bank of Communications")),
        ("CEB", _("China Everbright Bank")),
        ("CCB2", _("China Citic Bank")),
        ("GDB", _("Guangdong Development Bank")),
        ("SPDB", _("Shanghai Pudong Development Bank")),
        ("SDB", _("Shenzhen Development Bank"))
        )

STATE_CHOICES = (
    ('0', _("active")),
    ('1', _("expired")),
    ('2', _("inactive")),
    ('3', _("closed"))
    )

class CashAccount(models.Model):
    """
    现金账号
    """
    name = models.CharField(max_length=100, help_text=_("cash account name")) #账号名
    currency = models.CharField(max_length=3, choices=CASH_CHOICES, default='RMB', help_text=_("currency"))    #币种,整形对应特定的币种
    balance = models.FloatField(default=0, help_text=_("balance")) #账号现金数量
    owner = models.ForeignKey(User, help_text=_("owner")) #账户所属人
    state = models.CharField(max_length=1, choices=STATE_CHOICES, default='0', help_text=_("state")) #账户状态,0-正常，1-删除

    def __unicode__(self):
        """
        返回相关的信息
        """
        return "%s(%s)" % (self.name, self.owner.username)

    class Meta:
        verbose_name = _('Cash Account')
        verbose_name_plural = _('Cash Accounts')
 
class FixedTimeBankbookAccount(models.Model):
    """
    定期存折
    """
    name = models.CharField(max_length=100, help_text=_("Fixed Time bankbook account")) #账号名
    agent = models.CharField(max_length=4, choices=AGENT_CHOICES, help_text=_("Bank name"))    #账户所属机构,整形对应特定的机构
    currency = models.CharField(max_length=3, choices=CASH_CHOICES, help_text=_("currency"))    #币种,整形对应特定的币种
    balance = models.FloatField(default=0, help_text=_("balance")) #账号现金数量
    owner = models.ForeignKey(User, help_text=_("owner")) #账户所属人
    rate = models.FloatField(help_text=_("rate"))    #利率
    expire_date = models.DateField(max_length=100, blank=True, help_text=_("expire date")) #定期账户的定期时间,如半年,一年,5年等
    state = models.CharField(max_length=1, choices=STATE_CHOICES, default='0', help_text=_("state")) #账户状态,0-正常，1-删除

    def __unicode__(self):
        """
        返回相关的信息
        """
        return "%s(%s)" % (self.name, self.owner.username)

    class Meta:
        verbose_name = _('Fixed Time Bankbook Account')
        verbose_name_plural = _('Fixed Time Bankbook Accounts')

class DynamicTimeBankbookAccount(models.Model):
    """
    活期存折
    """
    name = models.CharField(max_length=100, help_text=_("Dynamic Time bankbook account")) #账号名
    agent = models.CharField(max_length=4, choices=AGENT_CHOICES, help_text=_("Bank name"))    #账户所属机构,整形对应特定的机构
    currency = models.CharField(max_length=3, choices=CASH_CHOICES, help_text=_("currency"))    #币种,整形对应特定的币种
    balance = models.FloatField(default=0, help_text=_("balance")) #账号现金数量
    owner = models.ForeignKey(User, help_text=_("owner")) #账户所属人
    rate = models.FloatField(help_text=_("rate"))    #利率
    state = models.CharField(max_length=1, choices=STATE_CHOICES, default='0', help_text=_("state")) #账户状态,0-正常，1-删除

    def __unicode__(self):
        """
        返回相关的信息
        """
        return "%s(%s)" % (self.name, self.owner.username)

    class Meta:
        verbose_name = _('Dynamic Time Bankbook Account')
        verbose_name_plural = _('Dynamic Time Bankbook Accounts')
 
class DebitcardAccount(models.Model):
    """
    借记卡
    """
    name = models.CharField(max_length=100, help_text=_("Debit Card account")) #账号名
    agent = models.CharField(max_length=4, choices=AGENT_CHOICES, help_text=_("Bank name"))    #账户所属机构,整形对应特定的机构
    currency = models.CharField(max_length=3, choices=CASH_CHOICES, help_text=_("currency"))    #币种,整形对应特定的币种
    balance = models.FloatField(default=0, help_text=_("balance")) #账号现金数量
    owner = models.ForeignKey(User, help_text=_("owner")) #账户所属人
    rate = models.FloatField(help_text=_("rate"))    #利率
    state = models.CharField(max_length=1, choices=STATE_CHOICES, default='0', help_text=_("state")) #账户状态,0-正常，1-删除

    def __unicode__(self):
        """
        返回相关的信息
        """
        return "%s(%s)" % (self.name, self.owner.username)

    class Meta:
        verbose_name = _('Debit Card Account')
        verbose_name_plural = _('Debit Card Accounts')

class StockAccount(models.Model):
    """
    股票账号
    """
    name = models.CharField(max_length=100, help_text=_("Stock account")) #账号名
    agent = models.CharField(max_length=4, choices=AGENT_CHOICES, help_text=_("Bank name"))    #账户所属机构,整形对应特定的机构
    currency = models.CharField(max_length=3, choices=CASH_CHOICES, help_text=_("currency"))    #币种,整形对应特定的币种
    balance = models.FloatField(default=0, help_text=_("balance")) #账号现金数量
    owner = models.ForeignKey(User, help_text=_("owner")) #账户所属人
    rate = models.FloatField(help_text=_("rate"))    #利率
    state = models.CharField(max_length=1, choices=STATE_CHOICES, default='0', help_text=_("state")) #账户状态,0-正常，1-删除

    def __unicode__(self):
        """
        返回相关的信息
        """
        return "%s(%s)" % (self.name, self.owner.username)
             
    class Meta:
        verbose_name = _('Stock Account')
        verbose_name_plural = _('Stock Accounts')

class CreditcardAccount(models.Model):
    """
    信用卡账号
    """
    name = models.CharField(max_length=100, help_text=_("Credit card account")) #账号名
    agent = models.CharField(max_length=4, choices=AGENT_CHOICES, help_text=_("Bank name"))    #账户所属机构,整形对应特定的机构
    currency = models.CharField(max_length=3, choices=CASH_CHOICES, help_text=_("currency"))    #币种,整形对应特定的币种
    balance = models.FloatField(default=0, help_text=_("balance")) #账号现金数量
    owner = models.ForeignKey(User, help_text=_("owner")) #账户所属人
    fine_rate = models.FloatField(help_text=_("fine rate")) #超期时的罚款比例
    charge_time = models.DateField(help_text=_("Charge time"))    #还款时间
    state = models.CharField(max_length=1, choices=STATE_CHOICES, default='0', help_text=_("state")) #账户状态,0-正常，1-删除

    def __unicode__(self):
        """
        返回相关的信息
        """
        return "%s(%s)" % (self.name, self.owner.username)

    class Meta:
        verbose_name = _('Credit card Account')
        verbose_name_plural = _('Credit card Accounts')

class InsuranceAccount(models.Model):
    """
    保险账号
    """
    name = models.CharField(max_length=100, help_text=_("Insurance account")) #账号名
    agent = models.CharField(max_length=4, choices=AGENT_CHOICES, help_text=_("Bank name"))    #账户所属机构,整形对应特定的机构
    currency = models.CharField(max_length=3, choices=CASH_CHOICES, help_text=_("currency"))    #币种,整形对应特定的币种
    balance = models.FloatField(default=0, help_text=_("balance")) #账号现金数量
    owner = models.ForeignKey(User, help_text=_("owner")) #账户所属人
    rate = models.FloatField(help_text=_("benifit rate"))    #利率
    state = models.CharField(max_length=1, choices=STATE_CHOICES, default='0', help_text=_("state")) #账户状态,0-正常，1-删除

    def __unicode__(self):
        """
        返回相关的信息
        """
        return "%s(%s)" % (self.name, self.owner.username)

    class Meta:
        verbose_name = _('Insurance Account')
        verbose_name_plural = _('Insurance Accounts')

class FundAccount(models.Model):
    """
    基金账号
    """
    name = models.CharField(max_length=100, help_text=_("Stock account")) #账号名
    agent = models.CharField(max_length=4, choices=AGENT_CHOICES, help_text=_("Bank name"))    #账户所属机构,整形对应特定的机构
    currency = models.CharField(max_length=3, choices=CASH_CHOICES, help_text=_("currency"))    #币种,整形对应特定的币种
    balance = models.FloatField(default=0, help_text=_("balance")) #账号现金数量
    owner = models.ForeignKey(User, help_text=_("owner")) #账户所属人
    rate = models.FloatField(help_text=_("benifit rate"))    #收益率
    time = models.IntegerField(help_text=_("expire time(year)"))    #年限
    state = models.CharField(max_length=1, choices=STATE_CHOICES, default='0', help_text=_("state")) #账户状态,0-正常，1-删除

    def __unicode__(self):
        """
        返回相关的信息
        """
        return "%s(%s)" % (self.name, self.owner.username)

    class Meta:
        verbose_name = _('Fund Account')
        verbose_name_plural = _('Fund Accounts')


